package com.woniuxy.java102vuecli.entity;

import com.woniuxy.java102vuecli.validationgroup.EmployeeAddGroup;
import com.woniuxy.java102vuecli.validationgroup.EmployeeModifyGroup;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

/**
 * @Author author
 * @Create 2023-09-13 15:34
 */

@NoArgsConstructor
@AllArgsConstructor
@Data
public class Employee {
    private Integer eid;
    // null "" "     "
//    @NotEmpty(message = "ename--NotEmpty")
//    @NotNull(message = "ename--NotNull")
    @NotBlank(message = "ename--NotBlank",groups = EmployeeAddGroup.class)
    @Size(min = 3, max = 6,message = "ename长度{min}-{max}",groups = EmployeeAddGroup.class)
    private String ename;
    private String password;
    private Boolean gender;
    private String genderstr;
    @NotBlank(message = "birthdate--NotBlank",groups ={EmployeeAddGroup.class, EmployeeModifyGroup.class})
    @Pattern(regexp ="^\\d{4}-\\d{2}-\\d{2}$",message = "日期格式错误",groups ={EmployeeAddGroup.class, EmployeeModifyGroup.class})
    private String birthdate;
    @NotBlank(message = "email--NotBlank",groups ={EmployeeAddGroup.class, EmployeeModifyGroup.class})
    @Pattern(regexp ="^\\w+@\\w+\\.\\w+$",message = "邮箱格式错误",groups ={EmployeeAddGroup.class, EmployeeModifyGroup.class})
    private String email;
    private Integer rid;
    private Integer isdelete;
    //关联属性，域属性
//    @Valid
//    @NotNull(message = "department--NotNull")
    private Department department;
}
